home *** CD-ROM | disk | FTP | other *** search
- global gurlpath
-
- on getData fieldname
- plist = [:]
- numlines = the number of lines in field fieldname
- numitems = the number of items in line 1 of field fieldname
- repeat with i = 2 to numlines
- tlist = [:]
- repeat with j = 1 to numitems
- var = item j of line i of field fieldname
- s = item j of line 1 of field fieldname
- addProp(tlist, symbol(s), var)
- end repeat
- if var <> EMPTY then
- addProp(plist, symbol(item 1 of line i of field fieldname), tlist)
- end if
- end repeat
- return plist
- end
-
- on setData plist, delim
- numlines = count(plist)
- numitems = count(plist[1])
- if ilk(plist) = #list then
- tabledata = EMPTY
- else
- tabledata = "id" & delim
- end if
- line1 = plist[1]
- repeat with i = 1 to numitems
- tabledata = tabledata & string(getPropAt(line1, i))
- if i <> numitems then
- tabledata = tabledata & delim
- next repeat
- end if
- tabledata = tabledata & RETURN
- end repeat
- repeat with i = 1 to numlines
- if ilk(plist) = #list then
- str = EMPTY
- else
- str = string(getPropAt(plist, i)) & delim
- end if
- repeat with j = 1 to numitems
- if ilk(plist[i][j]) = #symbol then
- str = str & "#" & string(plist[i][j])
- else
- str = str & plist[i][j]
- end if
- if j <> numitems then
- str = str & delim
- end if
- end repeat
- tabledata = tabledata & str & RETURN
- end repeat
- return tabledata
- end
-
- on getData2 fieldname, delim, props
- oldDel = the itemDelimiter
- the itemDelimiter = delim
- if props then
- plist = [:]
- else
- plist = []
- end if
- numlines = the number of lines in field fieldname
- numitems = the number of items in line 1 of field fieldname
- repeat with i = 2 to numlines
- tlist = [:]
- repeat with j = 1 to numitems
- var = item j of line i of field fieldname
- s = item j of line 1 of field fieldname
- addProp(tlist, symbol(s), var)
- end repeat
- if var <> EMPTY then
- if props then
- addProp(plist, symbol(item 1 of line i of field fieldname), tlist)
- next repeat
- end if
- append(plist, tlist)
- end if
- end repeat
- the itemDelimiter = oldDel
- return plist
- end
-
- on fixData plist
- lastbutton = count(plist)
- repeat with i = 1 to lastbutton
- lastitem = count(plist[i])
- repeat with j = 1 to lastitem
- if value(plist[i][j]) = VOID then
- if plist[i][j] = "0" then
- plist[i][j] = 0
- end if
- next repeat
- end if
- plist[i][j] = value(plist[i][j])
- end repeat
- end repeat
- return plist
- end
-
- on makeList fieldname
- numoflines = member(fieldname).line.count
- tlist = []
- repeat with i = 1 to numoflines
- if member(fieldname).line[i] <> EMPTY then
- add(tlist, member(fieldname).line[i])
- end if
- end repeat
- return tlist
- end
-
- on myGetPos sourcelist, prop
- counter = 1
- val = 0
- repeat with i in sourcelist
- if prop = getPropAt(sourcelist, counter) then
- val = counter
- exit repeat
- end if
- counter = counter + 1
- end repeat
- return val
- end
-
- on check val, tlist
- flag = 0
- repeat with i in tlist
- if i = val then
- flag = 1
- exit repeat
- end if
- end repeat
- return flag
- end
-
- on randomizelist theList
- newlist = []
- numofitems = count(theList)
- repeat with i = 1 to numofitems
- randompos = random(numofitems + 1 - i)
- itemfound = getAt(theList, randompos)
- add(newlist, itemfound)
- deleteAt(theList, randompos)
- numofitemsleft = numofitemsleft - 1
- end repeat
- return newlist
- end
-
- on query dtable, val, sfield, rfield
- tlist = []
- repeat with record in dtable
- if record[sfield] = val then
- if listp(rfield) then
- vtlist = [:]
- repeat with f in rfield
- addProp(vtlist, f, record[f])
- end repeat
- add(tlist, vtlist)
- next repeat
- end if
- add(tlist, record[rfield])
- end if
- end repeat
- return tlist
- end
-
- on swapChar2 str, ch1, ch2, numToSwap
- if voidp(numToSwap) then
- numToSwap = the maxinteger
- end if
- num = length(str)
- repeat with i = 1 to num
- if char i of str = ch1 then
- put ch2 into char i of str
- numToSwap = numToSwap - 1
- if numToSwap = 0 then
- exit repeat
- end if
- end if
- end repeat
- return str
- end
-
- on swapChar str, ch1, ch2
- num = length(str)
- repeat with i = 1 to num
- if char i of str = ch1 then
- put ch2 into char i of str
- end if
- end repeat
- return str
- end
-
- on removeChar2 str, charToRemove, numToRemove
- if voidp(numToRemove) then
- numToRemove = the maxinteger
- end if
- l = length(str)
- newstr = EMPTY
- repeat with i = 1 to l
- c = char i of str
- if c <> charToRemove then
- newstr = newstr & c
- next repeat
- end if
- numToRemove = numToRemove - 1
- if numToRemove = 0 then
- newstr = newstr & chars(str, i + 1, l)
- exit repeat
- end if
- end repeat
- return newstr
- end
-
- on removeChar str, charToRemove
- l = length(str)
- newstr = EMPTY
- repeat with i = 1 to l
- c = char i of str
- if c <> charToRemove then
- newstr = newstr & c
- end if
- end repeat
- return newstr
- end
-
- on toUpperCase str
- newstr = EMPTY
- l = length(str)
- repeat with i = 1 to l
- chid = charToNum(str.char[i])
- if (chid >= 97) and (chid <= 122) then
- chid = chid - 32
- end if
- newstr = newstr & numToChar(chid)
- end repeat
- return newstr
- end
-
- on toLowerCase str
- newstr = EMPTY
- l = length(str)
- repeat with i = 1 to l
- chid = charToNum(str.char[i])
- if (chid >= 65) and (chid <= 90) then
- chid = chid + 32
- end if
- newstr = newstr & numToChar(chid)
- end repeat
- return newstr
- end
-
- on firstletterUpper str
- newstr = toUpperCase(char 1 of str)
- newstr = newstr & chars(str, 2, length(str))
- return newstr
- end
-
- on dummyString numofchs, ch
- str = EMPTY
- repeat with i = 1 to numofchs
- str = str & ch
- end repeat
- return str
- end
-
- on checkIfNumber numstr
- len = length(numstr)
- isnum = 1
- repeat with i = 1 to len
- thischar = charToNum(char i of numstr)
- if (thischar >= 48) and (thischar <= 57) then
- nothing()
- next repeat
- end if
- isnum = 0
- exit repeat
- end repeat
- return isnum
- end
-
- on getPathDelim
- if (the environment).runMode = "plugin" then
- return "/"
- else
- if (the environment).platform contains "mac" then
- return ":"
- else
- return "\"
- end if
- end if
- end
-
- on getCastExt
- mode = (the environment).runMode
- case mode of
- "author":
- return ".cst"
- "projector":
- return ".cxt"
- "plugin":
- return ".cct"
- end case
- end
-
- on addMinutes begintime, gameduration
- oldDelimiter = the itemDelimiter
- the itemDelimiter = ":"
- currenthours = integer(item 1 of begintime)
- currentmins = integer(item 2 of begintime)
- currentsecs = integer(item 3 of begintime)
- the itemDelimiter = oldDelimiter
- hours2add = integer(gameduration / 60)
- minutes2add = integer(gameduration mod 60)
- newhours = hours2add + currenthours
- if (minutes2add + currentmins) > 59 then
- newminutes = minutes2add + currentmins - 60
- newhours = newhours + 1
- else
- newminutes = minutes2add + currentmins
- end if
- newsecs = currentsecs
- if newhours > 23 then
- newhours = newhours - 24
- end if
- if (newhours > -1) and (newhours < 10) then
- newhours = "0" & newhours
- end if
- if (newminutes > -1) and (newminutes < 10) then
- newminutes = "0" & newminutes
- end if
- if (newsecs > -1) and (newsecs < 10) then
- newsecs = "0" & newsecs
- end if
- newtime = newhours & ":" & newminutes & ":" & newsecs
- return newtime
- end
-
- on timeDifference time1, time2
- if time1 > time2 then
- t1 = time1
- t2 = time2
- else
- t1 = time2
- t2 = time1
- end if
- oldDel = the itemDelimiter
- the itemDelimiter = ":"
- t1hours = integer(item 1 of t1)
- t1mins = integer(item 2 of t1)
- t1secs = integer(item 3 of t1)
- t2hours = integer(item 1 of t2)
- t2mins = integer(item 2 of t2)
- t2secs = integer(item 3 of t2)
- thours = t1hours - t2hours
- tmins = t1mins - t2mins
- tsecs = t1secs - t2secs
- the itemDelimiter = oldDel
- mins = (thours * 60) + tmins
- secs = (mins * 60) + tsecs
- return secs
- end
-
- on pluraldetect t, str
- if t = 1 then
- tstr = str
- else
- tstr = str & "s"
- end if
- return tstr
- end
-
- on SortOutQuotes sz
- n = 1
- repeat while n < length(sz)
- if char n of sz = QUOTE then
- put QUOTE & ""E&" & QUOTE into char n of sz
- n = n + 9
- next repeat
- end if
- n = n + 1
- end repeat
- return sz
- end
-
- on propsplit plist
- namelist = []
- row1 = plist[1]
- numofcols = count(row1)
- repeat with i = 1 to numofcols
- append(namelist, getPropAt(row1, i))
- end repeat
- numofrows = count(plist)
- datalist = []
- repeat with row = 1 to numofrows
- tlist = []
- repeat with col = 1 to numofcols
- append(tlist, plist[row][col])
- end repeat
- append(datalist, tlist)
- end repeat
- return [namelist, datalist]
- end
-
- on propjoin theList
- newlist = []
- namelist = theList[1]
- datalist = theList[2]
- numofcols = count(namelist)
- numofrows = count(datalist)
- repeat with rows = 1 to numofrows
- tlist = [:]
- repeat with cols = 1 to numofcols
- addProp(tlist, namelist[cols], datalist[rows][cols])
- end repeat
- append(newlist, tlist)
- end repeat
- return newlist
- end
-
- on setScreenData sideTitleText, mainColor, subColor
- member("Side Title").text = sideTitleText
- member("Side Title").foreColor = mainColor
- member("Top Title0").foreColor = mainColor
- member("Top Title1").foreColor = mainColor
- member("Top Title2").foreColor = subColor
- end
-
- on addProps Data, propslist
- v = ilk(Data)
- if v <> #propList then
- newlist = [:]
- Data = [:]
- else
- newlist = duplicate(Data)
- end if
- repeat with p in propslist
- if myGetPos(Data, p) = 0 then
- addProp(newlist, p, -1200)
- end if
- end repeat
- return newlist
- end
-